Ext.define("admin.view.main.adminMenu", {
    extend: 'Ext.tree.Panel',
    alias: 'widget.main.adminMenu',
    border: false,
    rootVisible: false,
    listeners:{
        itemclick: function(t, record, item, index, e, eOpts){
            var id = record.id;
            var isLeaf = record.data.leaf;
            var type = record.data.xtype;
            var icon = record.data.icon;

            if(!isLeaf){
                return ;
            };

            if(!type){
                Ext.Msg.alert('提示','你还没有定义xtype属性');
                return;
            }
            var main_tab = Ext.getCmp(id);
            var main_tabpanel = Ext.getCmp("app-main");

            if(!main_tab)
            {
                main_tabpanel.add({
                    xtype: type,
                    title: record.data.text,
                    id: id,
                    itemId:id,
                    icon:icon,
                    closable: true
                });
            }
            main_tabpanel.setActiveItem(id);
        }
    }
});
